Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / ble / src / commonTest / kotlin / org / meshtastic / core / ble / BleExceptionClassifierTest.kt

Displaying Raw • Download

core/ble/src/commonTest/kotlin/org/meshtastic/core/ble/BleExceptionClassifierTest.kt renovate/net.java.dev.jna-jna-5.x (5a8f4966) Text, 2.40 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ble

Tff7b72import T7ee787com.juul.kable.GattStatusException
Tff7b72import T7ee787com.juul.kable.NotConnectedException
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals
Tff7b72import T7ee787kotlin.test.assertFalse
Tff7b72import T7ee787kotlin.test.assertNotNull
Tff7b72import T7ee787kotlin.test.assertNull
Tff7b72import T7ee787kotlin.test.assertTrue

T8b949e/**
* Tests for [classifyBleException] — the boundary between Kable types and the transport layer.
*
* [GattRequestRejectedException] and [UnmetRequirementException] have `internal` constructors in Kable, so they cannot
* be instantiated from outside the library. The `else -> null` branch covers the fallback for any unrecognised
* throwable.
*/
Tff7b72class T56d364BleExceptionClassifierTest Tb4b4b4{

Tf0883e@Test
Tff7b72fun Td2a8ff`GattStatusException maps to non-permanent with status code`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3ex Tff7b72= Te6edf3GattStatusExceptionTb4b4b4(Te6edf3message Tff7b72= Ta5d6ff"Ta5d6ffGATT failureTa5d6ff"Tb4b4b4, Te6edf3status Tff7b72= T79c0ff1T79c0ff3T79c0ff3Tb4b4b4)
Tff7b72val Te6edf3info Tff7b72= Te6edf3exTb4b4b4.Te6edf3classifyBleExceptionTb4b4b4(Tb4b4b4)
Te6edf3assertNotNullTb4b4b4(Te6edf3infoTb4b4b4)
Te6edf3assertFalseTb4b4b4(Te6edf3infoTb4b4b4.Te6edf3isPermanentTb4b4b4)
Te6edf3assertEqualsTb4b4b4(T79c0ff1T79c0ff3T79c0ff3Tb4b4b4, Te6edf3infoTb4b4b4.Te6edf3gattStatusTb4b4b4)
Te6edf3assertTrueTb4b4b4(Te6edf3infoTb4b4b4.Te6edf3messageTb4b4b4.Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ff133Ta5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`NotConnectedException maps to non-permanent without status code`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3ex Tff7b72= Te6edf3NotConnectedExceptionTb4b4b4(Ta5d6ff"Ta5d6ffdisconnectedTa5d6ff"Tb4b4b4)
Tff7b72val Te6edf3info Tff7b72= Te6edf3exTb4b4b4.Te6edf3classifyBleExceptionTb4b4b4(Tb4b4b4)
Te6edf3assertNotNullTb4b4b4(Te6edf3infoTb4b4b4)
Te6edf3assertFalseTb4b4b4(Te6edf3infoTb4b4b4.Te6edf3isPermanentTb4b4b4)
Te6edf3assertNullTb4b4b4(Te6edf3infoTb4b4b4.Te6edf3gattStatusTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffNot connectedTa5d6ff"Tb4b4b4, Te6edf3infoTb4b4b4.Te6edf3messageTb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`unrelated exception returns null`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3ex Tff7b72= Te6edf3IllegalStateExceptionTb4b4b4(Ta5d6ff"Ta5d6ffsomething elseTa5d6ff"Tb4b4b4)
Te6edf3assertNullTb4b4b4(Te6edf3exTb4b4b4.Te6edf3classifyBleExceptionTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`RuntimeException returns null`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertNullTb4b4b4(Te6edf3RuntimeExceptionTb4b4b4(Ta5d6ff"Ta5d6ffboomTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3classifyBleExceptionTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.07s